package com.example.demo.controller;

import com.example.demo.model.core.PageVo;
import com.example.demo.model.core.R;
import com.example.demo.model.form.LogForm;
import com.example.demo.model.query.LogQuery;
import com.example.demo.model.vo.LogVO;
import com.example.demo.service.SysLogService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/api/v1/log")
public class SysLogController {
    /**
     * 服务对象
     */
    @Resource
    private SysLogService sysLogService;

    /**
     * 分页查询
     *
     * @param query 筛选条件
     * @return 查询结果
     */
    @GetMapping("/page")
    public R<PageVo<LogVO>> queryByPage(LogQuery query) {
        return R.ok(sysLogService.page(query));
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public R<LogForm> queryById(@PathVariable("id") String id) {
        return R.ok(sysLogService.form(id));
    }


}

